package top.lilele.adminSystem.utils;

import lombok.Data;

import java.io.Serializable;


/**
 * 基础响应类，返回前端使用
 *
 * @author lilele
 */
@Data
public class BaseResponse implements Serializable {
    private Integer code;
    private String message;
    private Object data;

    public BaseResponse() {
    }

    public BaseResponse(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public BaseResponse(ResponseCodeEnum responseCodeEnum, Object data) {
        this.code = responseCodeEnum.getCode();
        this.message = responseCodeEnum.getMessage();
        this.data = data;
    }

    /**
     * code message info
     *
     * @param responseCodeEnum
     * @param data
     * @return
     */
    public static BaseResponse info(ResponseCodeEnum responseCodeEnum, Object data) {
        return new BaseResponse(responseCodeEnum, data);
    }


    /**
     * 基础全自定义 info
     *
     * @param code
     * @param message
     * @param data
     * @return
     */
    public static BaseResponse baseInfo(Integer code, String message, Object data) {
        return new BaseResponse(code, message, data);
    }
}
